package com.hzy.servlet;

import com.hzy.service.BookingService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Package: com.hzy.servlet
 * @ClassName: DeleteServlet
 * @Author: 862982795
 * @CreateTime: 2021/07/02 14:28
 * @Description:
 */
@WebServlet("/DeleteServlet")
public class DeleteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        resp.setCharacterEncoding("utf-8");

        Integer id=Integer.valueOf(req.getParameter("id"));

        BookingService service=new BookingService();
        Integer i=service.deleteBookingById(id);

        PrintWriter out=resp.getWriter();
        out.println(i);
        out.close();

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
